<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 15-5-24
 * Time: 下午11:08
 */

class coupon extends adminBase{
    function __construct(){
        parent::__construct();
        $this->cms->setPageTitle("管理面板");
        $this->cms->setActionTitle("销售管理");
        $this->cms->setControlFile("admin/tpl/coupon/coupon_control.json");
        $admin_info=$this->user->getLoginInfo();
        $user=UserMode::init();
        $levels=$user->getLevels($admin_info['id']);
        if(!$user->checkLevels(11,$levels)){
            $r['message']="您不具有此权限！";
            View::displayAsHtml($r,"plugin/state/tips.php");
            exit();
        }
    }

    function indexTask($page){
        $url=WebRouter::init()->getQuestion("page=");
        $page=$page>=1? $page: 1;
        $countOfPage=20;
        $offset=($page-1)*$countOfPage;
        $coupon=CouponMode::init();
        list($r['coupon'],$coupon_total)=$coupon->getAll(null,$countOfPage,$offset);
        $r['pages']=new Page($page,$coupon_total,$countOfPage);
        $r['pages']->setPageCallback(create_function('$page','return "'.$url.'".$page;'));
        $this->cms->tableScene($r,"admin/tpl/coupon/coupon.php");
    }

    function addTask(){
        $this->cms->formScene(array(),"admin/tpl/coupon/couponAdd.php");
    }
}